<?php

/**
 * This is the model class for table "luastanamproduksipadisawah".
 *
 * The followings are the available columns in table 'luastanamproduksipadisawah':
 * @property integer $ltpps_id
 * @property integer $ltpps_kec
 * @property integer $ltpps_tanam
 * @property integer $ltpps_panen
 * @property integer $ltpps_produksi
 * @property double $ltpps_rata
 * @property integer $ltpps_tahun
 *
 * The followings are the available model relations:
 * @property Kecamatan $ltppsKec
 */
class Luastanamproduksipadisawah extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Luastanamproduksipadisawah the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'luastanamproduksipadisawah';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ltpps_kec, ltpps_tanam, ltpps_panen, ltpps_produksi, ltpps_tahun', 'numerical', 'integerOnly'=>true),
			array('ltpps_rata', 'numerical'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ltpps_id, ltpps_kec, ltpps_tanam, ltpps_panen, ltpps_produksi, ltpps_rata, ltpps_tahun', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'ltppsKec' => array(self::BELONGS_TO, 'Kecamatan', 'ltpps_kec'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ltpps_id' => 'Ltpps',
			'ltpps_kec' => 'Kecamatan',
			'ltpps_tanam' => 'Luas Tanam(Ha)',
			'ltpps_panen' => 'Luas Panen(Ha)',
			'ltpps_produksi' => 'Produksi(Ton)',
			'ltpps_rata' => 'Rata-Rata',
			'ltpps_tahun' => 'Tahun',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ltpps_id',$this->ltpps_id);
		$criteria->compare('ltpps_kec',$this->ltpps_kec);
		$criteria->compare('ltpps_tanam',$this->ltpps_tanam);
		$criteria->compare('ltpps_panen',$this->ltpps_panen);
		$criteria->compare('ltpps_produksi',$this->ltpps_produksi);
		$criteria->compare('ltpps_rata',$this->ltpps_rata);
		$criteria->compare('ltpps_tahun',$this->ltpps_tahun);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}